home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_02_09
/
2n09065a
< prev
next >
Wrap
Text File
|
1991-07-24
|
654b
|
34 lines
// VIRTUAL.L - Demonstrate all member functions are virtual.
class base
{
print() { w << "Base class\n"; }
print2() { print(); }
baseprint() { base::print(); }
};
class derived : base
{
print() { w << "Derived class\n"; }
};
main() {
w = new textwindow ("base vs. derived");
w.show();
base b = new base;
derived d = new derived;
w << "b.print():";
b.print();
w << "b.print2():";
b.print2();
w << "b.baseprint():";
b.baseprint();
w << "d.print():";
d.print();
w << "d.print2():";
d.print2();
w << "d.baseprint():";
d.baseprint();
}